<template>
  <div class="lang">
    <assets-head :title="$t('语言设置')" />
    <div v-for="(item,index) in lang" :key="index" class="lang-padding" @click="handleSetLang(item.key)">
      <div class="lang-title flex items-center font-26 textColor">
        <img class="w-75 h-50 mr-24" :src="item.image" alt="">
        {{item.title}}
      </div>
      <div class="lang-flex"></div>
      <img v-if="item.key==$i18n.locale" src="../../assets/image/public/checked.png"
        style="width: 20px;height: 20px;" />
    </div>
  </div>
</template>
<script>
import { mapGetters, mapMutations } from "vuex";
import assetsHead from "@/components/assets-head";
import { setStorage } from '@/utils/utis'
export default {
  data() {
    return {
      lang: [
        { title: '繁体中文', key: 'CN', image: require('../../assets/image/lang/taiwan.png') },
        { title: '简体中文', key: 'zh-CN', image: require('../../assets/image/lang/zh-CN.png') },
        { title: 'English', key: 'en', image: require('../../assets/image/lang/en-US.png') },
        { title: '한국인', key: 'Korean', image: require('../../assets/image/lang/Korean.png') },
        { title: 'Deutsch', key: 'de', image: require('../../assets/image/lang/de.png') },
        { title: 'Français', key: 'fr', image: require('../../assets/image/lang/French.png') },
        { title: '日本語', key: 'Japanese', image: require('../../assets/image/lang/Japanese.png') },
        { title: 'ไทย', key: 'th', image: require('../../assets/image/lang/Thai.png') },
        // { title: 'español', key: 'es', image: require('../../assets/image/lang/Spanish.png') },
      ]
    }
  },
  components: {
    assetsHead,
  },
  computed: {
    ...mapGetters({
      activeLang: 'language'
    })
  },
  methods: {
    ...mapMutations('language', ['setLanguage']),
    handleSetLang(lang) {
      // 设置i18n.locale 组件库会按照上面的配置使用对应的文案文件
      this.$i18n.locale = lang
      // 提交mutations
      this.setLanguage(lang)
      setStorage('popNotice', false)
    },
    onClickLeft() {
      this.$router.push('/')
      console.log(this.$i18n.locale)
    },
  }
}
</script>
<style lang="scss" scoped>
.lang {
  width: 100%;
  box-sizing: border-box;
}

.CommonProblem-padding {
  padding-left: 50px;
  padding-right: 50px;
}

.lang-padding {
  padding: 43px 35px 43px 35px;
  box-sizing: border-box;
  border-bottom: 1px solid $line_color;
  font-weight: 400;
  font-size: 35px;
  color: #000000;
  display: flex;
}

.lang-flex {
  flex: 1;
}
</style>
